package com.example.demo1.common;
import lombok.Data;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 言初
 * Date: 2024-06-19
 * Time: 18:21
 */
// 前后端交互的统一对象


@Data
public class ResultAjax {
    private int code;
    private String msg;
    private  Object data;

    //成功
    public static ResultAjax succ(Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(200);
        result.setMsg("");
        result.setData(data);
        return result;
    }
    public static ResultAjax succ(int code,String msg,Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return  result;
    }

    //失败
    public static ResultAjax fail(int code,String msg){
        ResultAjax result = new ResultAjax();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(null);
        return  result;
    }
    public static ResultAjax fail(int code,String msg,Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return  result;
    }

}

